#include "processor.h"

processing_element::processing_element(unsigned int iq_size, unsigned int issue_width, processor &top, unsigned int ID)
{
	this->issue_width = issue_width;

	/////////////////////////////////////////////////////////////
	// Execution Lanes.
	/////////////////////////////////////////////////////////////
	Execution_Lanes = new lane[issue_width];


	//Local Register File
	localRegistersInt = (unsigned long long *) malloc (LOCAL_INT_REGS * sizeof(unsigned long long));
	localRegistersFp = (unsigned long long *) malloc (LOCAL_FP_REGS * sizeof(unsigned long long));
	free = true;
	my_ID = ID;
/*	myLSU = &LSU;
	my_ren_int = &REN_INT;
	my_ren_fp = &REN_FP;*/

	top_level = &top;
}

unsigned long long processing_element::read(unsigned int local_reg)
{
	return localRegisters[local_reg];
}

void processing_element::write(unsigned int phys_reg, unsigned long long value)
{
	localRegisters[phys_reg] = value;
}

bool processing_element::is_free()
{
	return free;
}

void processing_element::set_free(){
	free = true;
}

void processing_element::clear_free()
{
	free = false;
}

void processing_element::wakeup_int(unsigned int phys_reg)
{
	IQ_INT->wakeup(phys_reg);
}

void processing_element::wakeup_fp(unsigned int phys_reg)
{
	IQ_FP->wakeup(phys_reg);
}
